//放置公共方法
const getYearMonthDay = (date)=>{
     let year = date.getFullYear();
     let month  = date.getMonth(); //获取当前月份(0-11,0代表1月)
     let day = date.getDate(); //获取当前日(1-31)
     return {
         year,month,day
     }
}
const getDate = (year,month,day)=>{
    return new Date(year,month,day)
}
//将时间格式转为 new Date() => 2019-01-02
const transYearMothDay = (date,type)=>{
    var {  YYYY,YY,MM,M,DD,D,HH,H,FF,F,SS,S,weekday } = allDatePop(date);
    var result = ""
    switch(type){
        case "YYYY-MM-DD":{
            result = `${YYYY}-${MM}-${DD}`
            break;
        }
        case "YY-M-D":{
            result = `${YY}-${M}-${D}`
            break;
        }
        default:{
            result = `${YYYY}-${MM}-${DD} ${HH}:${FF}:${SS}`
            break;
        }    

    }
    return result

}
const allDatePop =(date)=>{
    let YYYY = date.getFullYear();//2019
    let YY = String(YYYY).slice(2);
    let M = date.getMonth()+1;
    let D = date.getDate();
    let H = date.getHours();
    let F = date.getMinutes();
    let S = date.getSeconds();
    let weekday = date.getDay();
    let HH = date.getHours()<10?`0${date.getHours()}`:date.getHours();
    let FF = date.getMinutes()<10?`0${date.getMinutes()}`:date.getMinutes();
    let SS = date.getSeconds()<10?`0${date.getSeconds()}`:date.getSeconds();
    let MM  = date.getMonth()+1<10?`0${date.getMonth()+1}`:date.getMonth()+1; //获取当前月份(0-11,0代表1月)
    let DD = date.getDate()<10?`0${date.getDate()}`:date.getDate(); //获取当前日(1-31)
    return {
        YYYY,YY,MM,M,DD,D,HH,H,FF,F,SS,S,weekday
    }

}
export {
    getYearMonthDay,
    getDate,
    allDatePop,
    transYearMothDay
}